// 打开调试
Lyx.debug = true;

// 配置模块文件
Lyx.config({
    baseUrl: "src/module/",
    paths: {
        "ajax": "ajax",
        "drag": "drag",
        "ui": "ui",
        "base": "base",
        "scroll": "scroll",
        "alert": "alert"
    }
});

let depends = {
    "base": [],
    "ui": ["base"],
    "ajax": [],
    "alert": ["ui", "drag", "scroll"],
    "drag": ["ui"],
    "scroll": ["ui", "drag", "base"]
};

let execute = {};
Lyx.execute = function (tabId, moduleId, callback) {
    Lyx.each(depends[moduleId], function (index, id) {
        if (!execute[id]) {
            Lyx.execute(tabId, id);
        }
    });
    chrome.tabs.executeScript(tabId, {
        file: "src/module/" + moduleId + ".js"
    }, callback);
    execute[moduleId] = true;
};

// 设置别名，Lyx依旧保留
Lyx.setAlias("_");

chrome.tabs.executeScript(null, {
    file: "src/tm.js"
});

chrome.tabs.executeScript(null, {
    file: "js/app-config.js"
});

// 加载用户主文件
Lyx.loadJs("contextMenu.js");